
import os
import global_var
from collections import deque


def importname_filename(modulename):
	return "\\".join( modulename.split(".") )+".brd"

def getSource(filename):
	return "".join( open(filename).readlines() )

def haveFile(filename):
	if ( os.path.isfile(global_var.g_libs_dir+filename) == True ):
		return global_var.g_libs_dir+filename
	elif ( os.path.isfile(global_var.g_project_dir+filename) == True ):
		return global_var.g_project_dir+filename
	else:
		return None

def getTokenList(lexer):
	tokenList = []
	while (True):
		token = lexer.token()
		if token == None: return deque( tokenList )
		tokenList.append(token)
